package com.bit.IO;

import java.io.*;

class Student implements Serializable {
    public int age;
    public String name;
    public int score;
}
public class IOTest6 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        Student s =  deserializeStudent();
        System.out.println(s.name);
        System.out.println(s.age);
        System.out.println(s.score);
    }
    private static void serStudent(Student student) throws IOException {
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("d:/student.txt"));
        objectOutputStream.writeObject(student);
        objectOutputStream.close();
    }
    private static Student deserializeStudent() throws IOException, ClassNotFoundException {
        ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream("d:/student.txt"));
        Student s = (Student) objectInputStream.readObject();
        return s;
    }
}
